package com.offcn.demo.controller;

import com.offcn.demo.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.HashMap;
import java.util.Map;

@Controller
public class SecondThymeleafController {
    /**
     * 访问localhost:8080 页面
     * 将数据message填充到templates/index2.html
     * @param model
     * @return
     */

    @GetMapping("/index2")
    public String index2(Model model){
        String s = "afjahgefg";
        User user = new User();
        user.setId(2);
        user.setName("牛逼");
        user.setAge(12);
        Map<String,Object> map=new HashMap<>();
        map.put("src1","1.jpg");
        map.put("src2","2.jpg");
        model.addAttribute("s", s);
        model.addAttribute("user", user);
        model.addAttribute("src", map);

        return "index2";
    }
}
